/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eps.modelo.javabeans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author luis
 */
@Entity
@Table(name = "T_Distrito")
@NamedQueries({
    @NamedQuery(name = "Distrito.findAll", query = "SELECT d FROM Distrito d"),
    @NamedQuery(name = "Distrito.findByTDistritoID", query = "SELECT d FROM Distrito d WHERE d.tDistritoID = :tDistritoID"),
    @NamedQuery(name = "Distrito.findByDescripcion", query = "SELECT d FROM Distrito d WHERE d.descripcion = :descripcion")})
public class Distrito implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "T_Distrito_ID")
    private Integer tDistritoID;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;
    @JoinColumn(name = "T_Localidad_ID", referencedColumnName = "T_Localidad_ID")
    @ManyToOne(optional = false)
    private Localidad tLocalidadID;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tDistritoID")
    private List<Sector> sectorList;

    public Distrito() {
    }

    public Distrito(Integer tDistritoID) {
        this.tDistritoID = tDistritoID;
    }

    public Distrito(Integer tDistritoID, String descripcion) {
        this.tDistritoID = tDistritoID;
        this.descripcion = descripcion;
    }

    public Integer getTDistritoID() {
        return tDistritoID;
    }

    public void setTDistritoID(Integer tDistritoID) {
        this.tDistritoID = tDistritoID;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Localidad getTLocalidadID() {
        return tLocalidadID;
    }

    public void setTLocalidadID(Localidad tLocalidadID) {
        this.tLocalidadID = tLocalidadID;
    }

    public List<Sector> getSectorList() {
        return sectorList;
    }

    public void setSectorList(List<Sector> sectorList) {
        this.sectorList = sectorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tDistritoID != null ? tDistritoID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Distrito)) {
            return false;
        }
        Distrito other = (Distrito) object;
        if ((this.tDistritoID == null && other.tDistritoID != null) || (this.tDistritoID != null && !this.tDistritoID.equals(other.tDistritoID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "murguia.ejb30.entity.COMER.Distrito[tDistritoID=" + tDistritoID + "]";
    }

}
